package com.cxyzy.demo

import com.cxyzy.demo.OkHttpUrl.BASE_URL
import com.cxyzy.demo.ext.getOkHttpClient
import com.cxyzy.demo.request.LoginReq
import com.google.gson.GsonBuilder
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

object HttpRepository {
    private val api: Api by lazy {
        val okHttpClient = getOkHttpClient()
        Retrofit.Builder()
                .baseUrl(BASE_URL)
                .client(okHttpClient)
                .addConverterFactory(GsonConverterFactory.create(GsonBuilder().create()))
                .build()
                .create(Api::class.java)
    }

    fun login(req: LoginReq) = api.login()
    suspend fun query() = api.query()

}